package ciyuan.Gui.DamageShow;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.particle.IParticleRenderType;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.world.ClientWorld;
import org.lwjgl.opengl.GL11;

/**
 * @author 150149
 */
public class DamageParticle extends net.minecraft.client.particle.Particle {

    private ClientWorld clientWorld;
    private static final FontRenderer fontRenderer;

    protected DamageParticle(ClientWorld clientWorld, double x, double y, double z,double speedX,double speedY,double speedZ) {
        super(clientWorld, x, y, z,speedX,speedY,speedZ);
        this.clientWorld=clientWorld;
        this.setLifetime(20);

    }

    @Override
    public void render(IVertexBuilder iVertexBuilder, ActiveRenderInfo activeRenderInfo, float p_225606_3_) {

        int color = ((int)((double)this.alpha * 64.0D) & 255) << 24 | ((100) / 2 & 255) << 16 | ((100) / 2 & 255) << 8 | ((100) / 2 & 255) << 0;

        GL11.glPushMatrix();
        GL11.glRotatef(-activeRenderInfo.getYRot(), 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(activeRenderInfo.getXRot(), 1.0F, 0.0F, 0.0F);
        GL11.glScalef(-1.0F, -1.0F, 1.0F);
        String num = "100";
        fontRenderer.draw(new MatrixStack(), num, (float)(-fontRenderer.width(num)) / 2.0F, 0.0F, color);

        GL11.glPopMatrix();

    }

    static {
        fontRenderer = Minecraft.getInstance().font;
    }

    @Override
    public IParticleRenderType getRenderType() {
        return IParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
    }
}
